<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<html>
<head>
    <title>投保暂存单</title>
    <%@include file="/WEB-INF/views/common.jsp"%>
    <script >
        $(function () {
            $("#search_panel").panel({
                title:"高级查询面板",
                fit:true
            });
            $("#orderBill_datagrid").datagrid({
                height:350,
                rownumbers:true,
                singleSelect:true,
                pagination:true,
                url:'/orderBill/selectBill?orderBillStatus=0',
                fitColumns:true,
                columns:[
                    [
                        {field:'ck',checkbox:true},
                        {field:'insureBillNumber',align:'center',width:200,title:'投保单号'},
                        {field:'apl_realname',align:'center',width:100,title:'投保人名称'},
                        {field:'carPlateNumber',align:'center',width:180,title:'车牌号'},
                        {field:'inputTime',align:'center',width:180,title:'投保申请时间'},
                        {field:'p_name',align:'center',width:180,title:'产品名称'},
                        {field:'status',align:'center',width:180,title:'状态',formatter:statusFormatter}
                    ]
                ]
            });
            $("a[data-cmd]").on("click",function(){
                //获取表单 高级查询条件, 封装到 qo中, 并且重新加载 datagrid
                var organizationNameD = $("[name=organizationNameD]").val();
                var insureBillNumberD = $("[name=insureBillNumberD]").val();
                var productName = $("[name=productName]").val();
                var carPlateNumberD = $("[name=carPlateNumberD]").val();
                var aplicantName = $("[name=aplicantName]").val();
                var recognizeeNameD = $("[name=recognizeeNameD]").val();
                var inputBeginDateD = $("[name=inputBeginDateD]").val();
                var inputEndDateD = $("[name=inputEndDateD]").val();
                $("#orderBill_datagrid").datagrid("load",{
                    organizationNameD:organizationNameD,
                    insureBillNumberD:insureBillNumberD,
                    productName:productName,
                    carPlateNumberD:carPlateNumberD,
                    aplicantName:aplicantName,
                    recognizeeNameD:recognizeeNameD,
                    inputBeginDateD:inputBeginDateD,
                    inputEndDateD:inputEndDateD
                });
            });
        });
        function reload() {
            $("#orderBill_datagrid").datagrid("reload");
        }
        //编辑暂存单
        function modify() {
            var rowdata = $("#orderBill_datagrid").datagrid("getSelected");
            if(rowdata){
                window.location.href="/orderBill/modify?orderBillId="+rowdata.id;
            }else{
                $.messager.alert("温馨提示","请选择需要修改的暂存单","warning");
            }
        }
        //软删除暂存单
        function remove() {
            var rowdata = $("#orderBill_datagrid").datagrid("getSelected");
            if(rowdata){
                $.messager.confirm("温馨提示","您确定需要删除该保单吗?",function(yes){
                    if(yes){
                        $.get("/orderBill/remove?orderBillId=" + rowdata.id ,function(data){
                            if(data.success){
                                $("#orderBill_datagrid").datagrid("reload");
                                $.messager.alert("温馨提示",data.msg,"info");
                            }else{
                                $.messager.alert("温馨提示",data.msg,"error");
                            }
                        },"json")
                    }
                });
            }else{
                $.messager.alert("温馨提示","请选择需要删除的保单","warning");
            }
        }

        function statusFormatter(value,record,index){
            if(value==0){
                return "<font color='#b0e0e6'>暂存单</font>";
            }
        }
    </script>
</head>
<body>
<div id="search_panel" >
        <form id="search_form" method="post">
            <table style="width: 100%">
                <tr>
                    <td><select name="organizationNameD" class="easyui-combobox"
                         data-options="label:'机构部门:',labelPosition:'before',prompt:'请选择机构部门', width:450,
                         valueField:'id',textField:'organizationName',url:'/organization/selectList'"/></td>
                    <td><input name="insureBillNumberD" class="easyui-textbox" data-options="label:'投保单号:',labelPosition:'before',prompt:'请输入保单号', width:250"></td>
                </tr>
                <tr>
                    <td><select name="productName" class="easyui-combobox"
                               data-options="label:'产品:',labelPosition:'before',prompt:'请选择产品名称', width:450,
                               valueField:'id',textField:'name',url:'/product/selectList'"/></td>
                    <td><input name="carPlateNumberD" class="easyui-textbox" data-options="label:'车牌号码:',labelPosition:'before',prompt:'请输入保单号', width:250"></td>
                </tr>
                <tr>
                    <td><input name="aplicantName" class="easyui-textbox" data-options="label:'投保人:',labelPosition:'before',prompt:'投保人名称', width:450"></td>
                </tr>
                <tr>
                    <td>
                    <input name="inputBeginDateD" class="easyui-datebox" data-options="label:'申请日期:',labelPosition:'before',width:250"/>
                    ~<input name="inputEndDateD" class="easyui-datebox" data-options="width:180"/></td>
                </tr>
            </table>
            <div align="right">
                <a class="easyui-linkbutton" iconCls="icon-search" data-options="width:80,text:'查询'" iconCls="icon-search" data-cmd="search"></a>
                <a class="easyui-linkbutton" iconCls="icon-reload" data-options="text:'刷新',width:80" onclick="reload()"></a>
            </div>
        </form>

        <div id="orderBill_datagrid"></div>

        <div >
            <a class="easyui-linkbutton" data-options="width:100" onclick="modify()">编辑</a>
            <a class="easyui-linkbutton" data-options="width:100" onclick="remove()">删除</a>
        </div>
</div>
</body>
</html>
